﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SD.Web
{
    public partial class Site : System.Web.UI.MasterPage
    {
        /// <summary>
        /// event page load
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">event data</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            userLink.NavigateUrl = "~/Views/LogIn_LogOut/PersonalPage.aspx?user=" + Session["User"];
            //check user logged in or not.
            //if not logged in, redirect user to login page
            if (Session["User"] == null)
                Response.Redirect("~/Views/LogIn_LogOut/login.aspx");
        }

        /// <summary>
        /// event when user click logout button
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">event data</param>
        protected void LogOffButton_Click(object sender, EventArgs e)
        {
            //remove session of user, redirect user to login page
            Session.Remove("User");
            Response.Redirect("~/Views/LogIn_LogOut/Login.aspx");
        }
    }
}